<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        function fun() {
            console.log('函数方法');
        }
        try {
            var fun = 10;
            fun();
        } catch (e) {
            console.log(e);
        }

        console.log('程序没有问题');

        try {
            function fun2(name) {
                if (name == undefined) {
                    throw { errMag: '未传参数', code: 10003 };
                }
                console.log(name);
            }
            fun2();
        } catch (e) {
            console.log(e.errMag);
        } finally {

        }

        console.log('fun2执行之后');
    </script>
</body>

</html>